// enum 枚举
// 理解一系列常亮集合
// 比如三原色，周一到周日，四个方位

// 1.数字枚举
// 没赋值，默认0起步，依次递增
enum Direction {
  Up,
  Down,
  Left,
  Right
}

console.log(Direction.Up)
console.log(Direction[0])

// 手动赋值，10开始起步，依次递增
enum DirectionOne {
  Up = 10,
  Down,
  Left,
  Right
}

console.log(DirectionOne.Right) // 13


// 2.字符串枚举
enum DirectionStr {
  Up = "UP",
  Down = "DOWN",
  Left = "LEFT",
  Right = "RIGHT",
}

// enum基本用法
const value = 'UP'
if (value === DirectionStr.Up) {
  console.log("go up!")
}



// 3.常亮 enum枚举
// 提升性能，想过详见index.js
// 直接把DirectionStrConst.Down转义成结果
const enum DirectionStrConst {
  Up = "UP",
  Down = "DOWN",
  Left = "LEFT",
  Right = "RIGHT",
}

const valueTwo = 'DOWN'
if (valueTwo === DirectionStrConst.Down) {
  console.log("go Down!")
}